package cn.chencaiju.web;

import java.util.Arrays;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/param/")
public class ParamController {
	
	@RequestMapping("/success")
	public String param1(int id,HttpSession session) {
		System.out.println(id);
		session.setAttribute("user", id);
		return "success";
	}
	@RequestMapping(path="/params",method=RequestMethod.GET)
	public String param2(String[] names) {
		System.out.println(Arrays.toString(names));
		return "success";
	}
	@RequestMapping(path="/dopost",method=RequestMethod.POST)
	public String param3(String[] posts,String[] categories,Model m) {
		System.out.println(Arrays.toString(posts));
		m.addAttribute("user", categories[0]);
		return "success";
	}
	@RequestMapping("/post_param")
	public String param4() {
		return "post_param";
	}
}
